package cn.xuexiyuan.kpi.entity;

import lombok.Data;

/**
 * @Description:
 * @Author 左龙龙
 * @Date 20-12-3
 * @Version 1.0
 **/
@Data
public class ResponseEntity<T> {
    private int code;
    private String msg;
    private T data;
    private Integer count;

    public static ResponseEntity buildSucess(Object data){
        return buildSucess(data, "sucess", null);
    }

    public static ResponseEntity buildSucess(Object data, Integer count){
        return buildSucess(data, "sucess", count);
    }

    public static ResponseEntity buildSucess(Object data, String msg, Integer count){
        ResponseEntity resp  = new ResponseEntity();
        resp.setData(data);
        resp.setCode(0);
        resp.setMsg(msg);
        resp.setCount(count);
        return resp;
    }

    public static ResponseEntity buildFail(String errMsg){
        ResponseEntity resp  = new ResponseEntity();
        resp.setCode(-1);
        resp.setMsg(errMsg);
        return resp;
    }
}
